<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="example">
    <my-component></my-component>
</div>
<script src="../js/vue.min.js"></script>
<script>
    //向子组件传递数据
    //省略extend方法，vue内部调用
    Vue.component('my-component', {
        data:function(){
            return {
                name:'xiaoming',
                age:20
            }
        },
        //模板里不支持驼峰的属性写法，需要转换为‘-’连接的属性写法
        template: '<div >{{name}}Parent<child1-component some="1 + 1"></child1-component><child2-component :some="1 + 3"></child2-component></div>',
        components: {
            'child1-component': {
                // 声明 props
                props: ['some'],
                template: '<div>{{some}}</div>',
                ready:function(){
                    console.log(this.some)
                }
            },
            'child2-component': {
                // 声明 props
                props: ['some'],
                template: '<div>{{some}}</div>',
                ready:function(){
                    console.log(this.some)
                }
            }
        }
    });
    // 创建根实例1
    new Vue({
        el: '#example'
    });
</script>
</body>
</html>